cmake_minimum_required(VERSION 3.10)
project(face_recognition_demo)

find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

# 设置全局编译选项
   set(CMAKE_CXX_STANDARD 17)
   set(CMAKE_CXX_STANDARD_REQUIRED ON)
   
   if(CMAKE_BUILD_TYPE STREQUAL "Release")
       # 设置全局Release模式优化选项
       set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -DNDEBUG -ffast-math")
       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1 -msse4.2 -mavx -mavx2")
       
       # 确保dlib使用相同优化
       set(DLIB_ENABLE_ASSERTS OFF CACHE BOOL "Disable asserts" FORCE)
       add_compile_definitions(DLIB_DISABLE_ASSERTS)
   endif()

add_subdirectory(../dlib dlib_build)

find_package(nadjieb_mjpeg_streamer REQUIRED)

include_directories(
    ${CMAKE_SOURCE_DIR}/include
    ${CMAKE_SOURCE_DIR}
)

add_executable(web_capture
    web_capture.cpp
    FaceRecognizer.cpp
    PerformanceTimer.cpp
    ConfigParser.cpp
)

target_link_libraries(web_capture
    dlib::dlib
    ${OpenCV_LIBS}
    nadjieb_mjpeg_streamer::nadjieb_mjpeg_streamer
)